package com.cy.store.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class TimerAspect {

    @Around("execution(* com.cy.store.service.impl.*.*(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {

        // 记录项目开始时间
        long start = System.currentTimeMillis();

        // 运行类
        Object result = pjp.proceed();

        // 记录项目结束时间
        long end = System.currentTimeMillis();

        System.err.println("耗时：" + (end-start));
        return result;

    }
}
